import Cookie from 'js-cookie' // 操作cookie
export default {
  state: {
    token: ''
  },
  mutations: {
    setToken(state, data) {
      state.token = data
      Cookie.set('token', data)
    },
    clearToken(state) {
      state.token = ''
      Cookie.remove('token')
    },
    getToken(state) {
      // vue刷新的时候token会丢失，为了避免丢失 所以要重新获取一下
      if (!Cookie.get('tagList')) {
        return
      }
      state.token = Cookie.get('token')
    }
  }
}
